<?php
/**
 * Created by PhpStorm.
 *
 * User: Administrator
 * Date: 2019/11/19
 * Time: 18:34
 */

namespace App\Services\Utils;


use App\Models\ChargingScheme;
use Illuminate\Support\Carbon;

class Utils
{
    public static function getApiPriceList()
    {
        $now_time = Carbon::now();
        $priceStr = ChargingScheme::whereTime('start_time', '<', $now_time)
            ->whereTime('end_time', '>', $now_time)
            ->first();
        if (!isset($priceStr)) {
            $priceStr = ChargingScheme::where('type', 'default')->first();
        }
        $priceList = json_decode($priceStr->prices);
        return $priceList;
    }
}